# We want to limit to Manager only
user = context.REQUEST.AUTHENTICATED_USER
if not user.has_role('Manager'):
  raise "Access Denied"

# Specify a list of model identities
modelIdentities = ["model01189586031619855627125"]

# Specify a vocabulary of components
componentMapping = [ ("text01190775960698642620023", "Textbox 1"),
                     ("datetimeselector01199681615259554570349", "Date 1") ]
                     
# Generate the CSV Data                                          
csv = context.exportAssessmentsAsCSV( modelIdentities, componentMapping )
                     
### Optionally, you can filter on repositories. Comment out the above line and uncomment the following the use

#repositoryIdentities = ["repo01199668522712991289917"]                    
#csv = context.exportAssessmentsAsCSV( modelIdentities, componentMapping, repositoryIdentities )
        
# Tell the web browser we are sending a CSV file    
context.REQUEST.RESPONSE.setHeader( "content-type", "text/csv" )
context.REQUEST.RESPONSE.setHeader( "content-disposition" , "attachment; filename=assessments.csv" )                     
                     
return csv
